<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .one{
            width: 400px;
            height: 600px;
            margin:auto;
            padding: 0;
            border: 2px solid red;
        }
        img{
            width: 340px;
            height: 400px;
            margin-left: 30px;
            margin-top: 20px;
        }
        .header{
            font-size: 14px;
            color: pink;
            text-align: center;
        }
        #shu{
            font-size: 15px;
            font-weight: 600px;
        }
        #jiage,#ji{
            height: 20px;
            color: red;
            font-size: 30px;
            line-height: 20px;
            font-weight: 600;
            margin-top: 0;
        }
        #ji{
            margin-left: 150px;
        }
        .two{
            width: 300px;
            height: 30px;
            text-align: center;
            margin: auto;
            font-weight: 600;
        }
        button{
            width: 40px;
            height: 40px;
        }
        input{
            width: 100px;
            height: 30px;
        }
        .zong{
            font-size: 20px;
            margin-top: 0;
        }
        #zongjia{
            font-weight: 600;
            border: none;
        }
    </style>
</head>
<body>
    <div class="one">
        <img src="haha.jpg" alt="">
        <p class="header">无节操的老哈,有些天真有些傻，但是快乐就够了！</p>
        <p id="ji">￥<span id="jiage">250</span> </p>
       
    <div class="two">
        <span>数量</span> 
        <button id="jian">-</button>
        <input type="text" id="shu" min="0"value="0">
        <button id="jia">+</button>
        <p class="zong">总价￥:
        <input type="text" id="zongjia"value="0">
        </p>
    </div>
    </div>
    <script>
        // 点击一次加号+1；
        jia.onclick =function(){
        shu.value=parseInt(shu.value)+1;
        sum()
        }
        // 点击减号，减去1；
        jian.onclick=function(){
            shu.value=parseInt(shu.value)-1;
            if(shu.value<0){
                shu.value=0;
            }
        sum()
        }
        //  计算总的价格=数量*单价
        function sum(){
          zongjia.value=jiage.innerHTML* shu.value
        }
    </script>
</body>
</html>